package com.github.postsanf.yinian.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.github.postsanf.yinian.R;
import com.github.postsanf.yinian.activity.StealPhotosYearActivity;
import com.github.postsanf.yinian.bean.StealPhotoDate;

import java.util.ArrayList;
import java.util.List;

public class StealPhotosDateAdapter extends BaseAdapter {
    private List<StealPhotoDate> datas = new ArrayList<>();
    private Context context;
    private LayoutInflater inflater;

    public StealPhotosDateAdapter(Context context, List<StealPhotoDate> datas) {
        this.context = context;
        this.datas = datas;
        this.inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return datas.size();
    }

    @Override
    public Object getItem(int position) {
        return datas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView,
                        ViewGroup parent) {
        StealPhotoDate stealPhotoDate = datas.get(position);
        ViewHold viewHold = null;
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.yn_item_stealphotodate,
                    null);
            viewHold = new ViewHold();
            viewHold.item = (LinearLayout) convertView
                    .findViewById(R.id.stealdate_item);
            viewHold.name = (TextView) convertView
                    .findViewById(R.id.stealdate_item_name);
            viewHold.pic = (ImageView) convertView
                    .findViewById(R.id.stealdate_item_pic);
            convertView.setTag(viewHold);
        } else {
            viewHold = (ViewHold) convertView.getTag();
        }
        viewHold.name.setText(stealPhotoDate.getYear() + "年");
//        final int num = stealPhotoDate.getNum();
//        viewHold.item.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//
//            }
//        });
        return convertView;
    }

    class ViewHold {
        private LinearLayout item;
        private ImageView pic;
        private TextView name;
    }


}
